/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package UML_ER.impl;

import UML_ER.Entity;
import UML_ER.Generalization;
import UML_ER.GeneralizationCategory;
import UML_ER.UML_ERPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Generalization</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link UML_ER.impl.GeneralizationImpl#getSpecific <em>Specific</em>}</li>
 *   <li>{@link UML_ER.impl.GeneralizationImpl#getGeneralizationCategory <em>Generalization Category</em>}</li>
 *   <li>{@link UML_ER.impl.GeneralizationImpl#getGeneral <em>General</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GeneralizationImpl extends ElementImpl implements Generalization {
	/**
	 * The cached value of the '{@link #getSpecific() <em>Specific</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSpecific()
	 * @generated
	 * @ordered
	 */
	protected Entity specific;
	/**
	 * The cached value of the '{@link #getGeneralizationCategory() <em>Generalization Category</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGeneralizationCategory()
	 * @generated
	 * @ordered
	 */
	protected GeneralizationCategory generalizationCategory;
	/**
	 * The cached value of the '{@link #getGeneral() <em>General</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGeneral()
	 * @generated
	 * @ordered
	 */
	protected Entity general;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GeneralizationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return UML_ERPackage.Literals.GENERALIZATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity getSpecific() {
		if (specific != null && specific.eIsProxy()) {
			InternalEObject oldSpecific = (InternalEObject)specific;
			specific = (Entity)eResolveProxy(oldSpecific);
			if (specific != oldSpecific) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, UML_ERPackage.GENERALIZATION__SPECIFIC, oldSpecific, specific));
			}
		}
		return specific;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity basicGetSpecific() {
		return specific;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSpecific(Entity newSpecific) {
		Entity oldSpecific = specific;
		specific = newSpecific;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UML_ERPackage.GENERALIZATION__SPECIFIC, oldSpecific, specific));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public GeneralizationCategory getGeneralizationCategory() {
		if (generalizationCategory != null && generalizationCategory.eIsProxy()) {
			InternalEObject oldGeneralizationCategory = (InternalEObject)generalizationCategory;
			generalizationCategory = (GeneralizationCategory)eResolveProxy(oldGeneralizationCategory);
			if (generalizationCategory != oldGeneralizationCategory) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, UML_ERPackage.GENERALIZATION__GENERALIZATION_CATEGORY, oldGeneralizationCategory, generalizationCategory));
			}
		}
		return generalizationCategory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public GeneralizationCategory basicGetGeneralizationCategory() {
		return generalizationCategory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGeneralizationCategory(GeneralizationCategory newGeneralizationCategory) {
		GeneralizationCategory oldGeneralizationCategory = generalizationCategory;
		generalizationCategory = newGeneralizationCategory;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UML_ERPackage.GENERALIZATION__GENERALIZATION_CATEGORY, oldGeneralizationCategory, generalizationCategory));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity getGeneral() {
		if (general != null && general.eIsProxy()) {
			InternalEObject oldGeneral = (InternalEObject)general;
			general = (Entity)eResolveProxy(oldGeneral);
			if (general != oldGeneral) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, UML_ERPackage.GENERALIZATION__GENERAL, oldGeneral, general));
			}
		}
		return general;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity basicGetGeneral() {
		return general;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGeneral(Entity newGeneral) {
		Entity oldGeneral = general;
		general = newGeneral;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UML_ERPackage.GENERALIZATION__GENERAL, oldGeneral, general));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case UML_ERPackage.GENERALIZATION__SPECIFIC:
				if (resolve) return getSpecific();
				return basicGetSpecific();
			case UML_ERPackage.GENERALIZATION__GENERALIZATION_CATEGORY:
				if (resolve) return getGeneralizationCategory();
				return basicGetGeneralizationCategory();
			case UML_ERPackage.GENERALIZATION__GENERAL:
				if (resolve) return getGeneral();
				return basicGetGeneral();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case UML_ERPackage.GENERALIZATION__SPECIFIC:
				setSpecific((Entity)newValue);
				return;
			case UML_ERPackage.GENERALIZATION__GENERALIZATION_CATEGORY:
				setGeneralizationCategory((GeneralizationCategory)newValue);
				return;
			case UML_ERPackage.GENERALIZATION__GENERAL:
				setGeneral((Entity)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case UML_ERPackage.GENERALIZATION__SPECIFIC:
				setSpecific((Entity)null);
				return;
			case UML_ERPackage.GENERALIZATION__GENERALIZATION_CATEGORY:
				setGeneralizationCategory((GeneralizationCategory)null);
				return;
			case UML_ERPackage.GENERALIZATION__GENERAL:
				setGeneral((Entity)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case UML_ERPackage.GENERALIZATION__SPECIFIC:
				return specific != null;
			case UML_ERPackage.GENERALIZATION__GENERALIZATION_CATEGORY:
				return generalizationCategory != null;
			case UML_ERPackage.GENERALIZATION__GENERAL:
				return general != null;
		}
		return super.eIsSet(featureID);
	}

} //GeneralizationImpl
